{% include 'front/header1.html' %}
<style type="text/css">
	body{
		background: #fff !important;
	}
	.change-pwd {
		width: 7.466666rem;
		margin: auto;
	}
	
	.change-btn {
		margin-top: 1.333333rem;
	}
	
	input {
		margin-bottom: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		color: #666 !important;
		margin-top: 0.266666rem;
		font-size: 0.32rem !important;
	}
	
	.weui-cell__bd:after {
		content: "";
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 0.026666rem;
		background: #999;
	}
	.forget-pwd{
		margin-top: 0.266666rem;
	}
	.forget-pwd img{
		margin-right: 0.186666rem;
		width: 0.346666rem;
		height: 0.346666rem;
	}
	.content{
		background: #fff;
	}
</style>
<header class="mui-bar mui-bar-nav">
	<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	<h1 class="mui-title">修改密码</h1>
</header>
<div class="content">
	<div class="change-pwd">
		<div class="weui-cells weui-cells_form" id="form">
			<div class="weui-cell weui-cell_warn">
				<div class="weui-cell__bd">
					<input type="password" field="password" errmsg="请输入新的登录密码"  required="true" class="weui-input" type="number" placeholder="请输入您的登录密码">
				</div>
			</div>
			<div class="weui-cell weui-cell_warn">
				<div class="weui-cell__bd">
					<input type="password" field="password1" errmsg="请输入确认新的登录密码"  required="true" class="weui-input" type="number" placeholder="确认新的登录密码">
				</div>
			</div>
			<p class="forget-pwd"><img src="/resource/front/images/forward/icon-tishi.png"/>密码需为6位 以上的数字</p>
		</div>

		<div class="btn change-btn">
			完成
		</div>
	</div>
</div>
{% include 'front/foot.html' %}
<script>
	mui.ready(function() {
		this.changePwd();  //修改密码
		
	})
	
	function changePwd(){
		$('.change-btn').click(function(){
			var data = util.getFormCode({el:"#form"})
			if(!data.password){
				mui.toast("登录密码不能为空");
				return false;
			}
//			if(!(/^\d{6}\b/.test(data.password))){
//				mui.toast("密码需为6位 以上的数字");
//				return false;
//			}
			if(!data.password1){
				mui.toast("确认密码不能为空");
				return false;
			}
//			if(!(/^\d{6}\b/.test(data.password1))){
//				mui.toast("密码需为6位 以上的数字");
//				return false;
//			}
			if(data.password1 != data.password){
				mui.toast("两次密码不一致");
				return false;
			}
//			return false;
			util.doAjax({
				url: "/api/user/chanpwd_pwd",
				method: "post",
				data: {
					mobile:util.getUrlParam('phone'),
					pwd:data.password
				},
				success: function(res) {
					mui.toast("修改密码成功");
					setTimeout(function(){
						window.history.go(-2);
					},500)
					
				}
			})
			
		})
}
</script>